/*
 *接口编写处...
*如果接口需要做Action的权限验证，请在Action上使用属性
*如: [ApiActionPermission("bas_label",Enums.ActionPermissionOptions.Search)]
 */
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using DGZImp.BasProject.DomainModels;
using DGZImp.BasProject.IServices;
using DGZImp.Core.Utilities.Response;
using DGZImp.WmsProject.Dtos;

namespace DGZImp.BasProject.Controllers
{
    public partial class Bas_LabelController
    {
        private readonly IBas_LabelService _service;//访问业务代码
        private readonly IHttpContextAccessor _httpContextAccessor;

        [ActivatorUtilitiesConstructor]
        public Bas_LabelController(
            IBas_LabelService service,
            IHttpContextAccessor httpContextAccessor
        )
        : base(service)
        {
            _service = service;
            _httpContextAccessor = httpContextAccessor;
        }


        /// <summary>
        /// 获取视图字段
        /// </summary>
        /// <param name="ViewName"></param>
        /// <returns></returns>
        [HttpGet("GetViewField")]
        public async Task<ApiResponse<List<string>>> GetViewField([FromQuery] string ViewName)
        {
            var r = Service.GetViewField(ViewName);
            return ApiRes.Success(r);
        }

        /// <summary>
        /// 更新画布模板内容
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        [HttpPost("UpdateContent")]
        public async Task<ApiResponse<int>> UpdateContent([FromBody] ReqUpdateContent req)
        {
            var r = await Service.UpdateContent(req);
            return ApiRes.Success(r);
        }

        /// <summary>
        /// 创建更新模板明细
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        [HttpPost("ModifyLabelDesign")]
        public async Task<ApiResponse<string>> ModifyLabelDesign([FromBody] ReqModifyLabelDesign req)
        {
            var r = await Service.ModifyLabelDesign(req);
            return ApiRes.Success(r);
        }

        [HttpGet("Getbyid")]
        public async Task<ApiResponse<Bas_Label>> Getbyid(long? id, int type = 0)
        {
            var res = await Service.Getbyid(id, type);
            return ApiRes.Success(res);
        }

        [HttpGet("GetLabelConfigDetail")]
        public async Task<ApiResponse<List<Bas_LabelConfigDetail>>> GetLabelConfigDetail(long? LabelId)
        {
            var res = await Service.GetLabelConfigDetail(LabelId);
            return ApiRes.Success(res);
        }
    }
}
